<extend name="Public/base"/>

<block name="body">
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<div class="main-title">
		<h2>{$info['banner_id']?'编辑':'新增'}轮播图</h2>
	</div>
	<form action="{:U()}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">类型</label>
            <div class="controls">
                <select name="type">
                    <option value="1" <eq name="info.type" value="1">selected</eq>>轮播图</option>
                    <option value="0" <eq name="info.type" value="0">selected</eq>>广告图</option>
                </select>
            </div>
        </div>
		<div class="form-item">
			<label class="item-label">标题</label>
			<div class="controls">
				<input type="text" class="text input-large" name="title" value="{$info.title}">
			</div>
		</div>
		<div class="form-item">
			<label class="item-label">跳转地址<span class="check-tips">（外部链接请填写完整地址，带"http://"）</span></label>
			<div class="controls">
			<input type="text" class="text input-large" name="url" value="{$info.url}">
			</div>
		</div>
		<div class="form-item">
			<label class="item-label">打开方式</label>
			<div class="controls">
			<select name="opens">
					<option value="_blank" <eq name="info.opens" value="_blank">selected</eq>>新窗口</option>
					<option value="_self" <eq name="info.opens" value="_self">selected</eq>>当前窗口</option>
			</select>
			</div>
		</div>
        <div class="controls">
            <label class="item-label">轮播图片</label>
            <input type="file" id="upload_picture">
            <input type="hidden" name="img" id="img" value="{$info['img']|default=''}"/>
            <div class="upload-img-box">
                <notempty name="info['img']">
                    <div class="upload-pre-item"><img src="{$info.img|get_cover='path'}"/></div>
                </notempty>
            </div>
        </div>
        <script type="text/javascript">
            //上传图片
            /* 初始化上传插件 */
            $("#upload_picture").uploadify({
                "height": 30,
                "swf": "__STATIC__/uploadify/uploadify.swf",
                "fileObjName": "download",
                "buttonText": "上传图片",
                "uploader": "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                "width": 120,
                'removeTimeout': 1,
                'fileTypeExts': '*.jpg; *.png; *.gif;',
                "onUploadSuccess": uploadPicture,
                'onFallback': function() {
                    alert('未检测到兼容版本的Flash.');
                }
            });
            function uploadPicture(file, data) {
                var data = $.parseJSON(data);
                var src = '';
                if (data.status) {
                    $("#img").val(data.id);
                    src = data.url || '__ROOT__' + data.path;
                    $("#img").parent().find('.upload-img-box').html(
                    '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                    );
                } else {
                    updateAlert(data.info);
                    setTimeout(function() {
                    $('#top-alert').find('button').click();
                    $(that).removeClass('disabled').prop('disabled', false);
                    }, 1500);
                }
            }
        </script>
        <script type="text/javascript">
            UE.getEditor('myEditor', {
                theme:"default", //皮肤
                lang:"zh-cn", //语言
                initialFrameWidth:800,  //初始化编辑器宽度,默认800
                initialFrameHeight:320
            });
        </script>
		<div class="form-item">
			<label class="item-label">排序</label>
			<div class="controls">
				<input type="text" class="text input-large" name="sort" value="{$info.sort|default=50}">
			</div>
		</div>
		<div class="form-item">
			<input type="hidden" name="banner_id" value="{$info.banner_id|default=0}">
			<button class="btn submit-btn " id="submit" type="submit" target-form="form-horizontal">确 定</button>
			<button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
		</div>
	</form>

</block>



<block name="script">

	<script type="text/javascript">

		//导航高亮

		var mname="Banner";

		highlight_subnav("{:U('Banner/index')}");

	</script>

</block>

